package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Date;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "planreceivable_", schema = "crm")
public class Planreceivable {
    private int planreceivableId;//计划回款id
    private Date planreceivableDate;//日期
    private String planreceivableNote;//备注
    private Integer planreceivableBack;//是否回款
    private Integer planreceivableIssue;//期次
    private BigDecimal planreceivableMoney;//金额
    private String planreceivableEmpName;//所有者
    private String planreceivablePrincipal;//负责人
    private Contract contractByContractId;//合同订单
    private Employee employeeByEmpId;//员工(我方签约人)
    private Customer customerByCustomerId;//客户(客户签约人)

//    private Integer planreceivableAppStatus;
    private Employee employeeByAppEmpId;
//    private List<Approval> approvalsByPlanreceivableId;
//    private List<ApprovalRecord> approvalRecordsByPlanreceivableId;

    //private String planreceivableCustomerName;//客户
    @Id
    @Column(name = "planreceivable_id", nullable = false)
    public int getPlanreceivableId() {
        return planreceivableId;
    }

    public void setPlanreceivableId(int planreceivableId) {
        this.planreceivableId = planreceivableId;
    }


    @Basic
    @Column(name = "planreceivable_date", nullable = true)
    public Date getPlanreceivableDate() {
        return planreceivableDate;
    }

    public void setPlanreceivableDate(Date planreceivableDate) {
        this.planreceivableDate = planreceivableDate;
    }

    @Basic
    @Column(name = "planreceivable_note", nullable = true, length = 255)
    public String getPlanreceivableNote() {
        return planreceivableNote;
    }

    public void setPlanreceivableNote(String planreceivableNote) {
        this.planreceivableNote = planreceivableNote;
    }

    @Basic
    @Column(name = "planreceivable_back", nullable = true)
    public Integer getPlanreceivableBack() {
        return planreceivableBack;
    }

    public void setPlanreceivableBack(Integer planreceivableBack) {
        this.planreceivableBack = planreceivableBack;
    }

    @Basic
    @Column(name = "planreceivable_issue", nullable = true)
    public Integer getPlanreceivableIssue() {
        return planreceivableIssue;
    }

    public void setPlanreceivableIssue(Integer planreceivableIssue) {
        this.planreceivableIssue = planreceivableIssue;
    }

    @Basic
    @Column(name = "planreceivable_money", nullable = true, precision = 2)
    public BigDecimal getPlanreceivableMoney() {
        return planreceivableMoney;
    }

    public void setPlanreceivableMoney(BigDecimal planreceivableMoney) {
        this.planreceivableMoney = planreceivableMoney;
    }

   /* @Basic
    @Column(name = "planreceivable_customer_name", nullable = true, length = 255)
    public String getPlanreceivableCustomerName() {
        return planreceivableCustomerName;
    }

    public void setPlanreceivableCustomerName(String planreceivableCustomerName) {
        this.planreceivableCustomerName = planreceivableCustomerName;
    }*/

    @Basic
    @Column(name = "planreceivable_emp_name", nullable = true, length = 255)
    public String getPlanreceivableEmpName() {
        return planreceivableEmpName;
    }

    public void setPlanreceivableEmpName(String planreceivableEmpName) {
        this.planreceivableEmpName = planreceivableEmpName;
    }

    @Basic
    @Column(name = "planreceivable_principal", nullable = true, length = 255)
    public String getPlanreceivablePrincipal() {
        return planreceivablePrincipal;
    }

    public void setPlanreceivablePrincipal(String planreceivablePrincipal) {
        this.planreceivablePrincipal = planreceivablePrincipal;
    }

   /* @Basic
    @Column(name = "planreceivable_app_status", nullable = true, length = 255)
    public Integer getPlanreceivableAppStatus() {
        return planreceivableAppStatus;
    }

    public void setPlanreceivableAppStatus(Integer planreceivableAppStatus) {
        this.planreceivableAppStatus = planreceivableAppStatus;
    }*/

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Planreceivable that = (Planreceivable) o;
        return planreceivableId == that.planreceivableId &&
                Objects.equals(planreceivableDate, that.planreceivableDate) &&
                Objects.equals(planreceivableNote, that.planreceivableNote) &&
                Objects.equals(planreceivableBack, that.planreceivableBack) &&
                Objects.equals(planreceivableIssue, that.planreceivableIssue) &&
                Objects.equals(planreceivableMoney, that.planreceivableMoney) &&
                Objects.equals(planreceivableEmpName, that.planreceivableEmpName) &&
                //                Objects.equals(planreceivableCustomerName, that.planreceivableCustomerName) &&
                Objects.equals(planreceivablePrincipal, that.planreceivablePrincipal);
    }

    @Override
    public int hashCode() {
        return Objects.hash(planreceivableId, planreceivableDate, planreceivableNote, planreceivableBack, planreceivableIssue, planreceivableMoney, planreceivableEmpName, planreceivablePrincipal);
    }
    @ManyToOne
    @JoinColumn(name = "emp_id", referencedColumnName = "emp_id")
    public Employee getEmployeeByEmpId() {
        return employeeByEmpId;
    }

    public void setEmployeeByEmpId(Employee employeeByEmpId) {
        this.employeeByEmpId = employeeByEmpId;
    }

    @ManyToOne
    @JoinColumn(name = "customer_id", referencedColumnName = "customer_id")
    public Customer getCustomerByCustomerId() {
        return customerByCustomerId;
    }

    public void setCustomerByCustomerId(Customer customerByCustomerId) {
        this.customerByCustomerId = customerByCustomerId;
    }

    @ManyToOne
    @JoinColumn(name = "contract_id", referencedColumnName = "contract_id")
    public Contract getContractByContractId() {
        return contractByContractId;
    }

    public void setContractByContractId(Contract contractByContractId) {
        this.contractByContractId = contractByContractId;
    }

    @ManyToOne
    @JoinColumn(name = "app_emp_id", referencedColumnName = "emp_id")
    public Employee getEmployeeByAppEmpId() {
        return employeeByAppEmpId;
    }

    public void setEmployeeByAppEmpId(Employee employeeByAppEmpId) {
        this.employeeByAppEmpId = employeeByAppEmpId;
    }

   /* @OneToMany(mappedBy = "planreceivableByPlanreceivableId")
    public List<Approval> getApprovalsByPlanreceivableId() {
        return approvalsByPlanreceivableId;
    }

    public void setApprovalsByPlanreceivableId(List<Approval> approvalsByPlanreceivableId) {
        this.approvalsByPlanreceivableId = approvalsByPlanreceivableId;
    }*/

    /*@OneToMany(mappedBy = "planreceivableByPlanreceivableId")
    public List<ApprovalRecord> getApprovalRecordsByPlanreceivableId() {
        return approvalRecordsByPlanreceivableId;
    }

    public void setApprovalRecordsByPlanreceivableId(List<ApprovalRecord> approvalRecordsByPlanreceivableId) {
        this.approvalRecordsByPlanreceivableId = approvalRecordsByPlanreceivableId;
    }*/
}
